home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / remote / multnode.zip / BBS.BAT next >
DOS Batch File  |  1991-06-01  |  16KB  |  482 lines

  1. @echo off
  2. cls
  3. rem ******************************************************
  4. rem *                                                    *
  5. rem * BBS.BAT file for 3 Node BBS under DesQView.        *
  6. rem * Nodes 1 & 2 run the Front Door Mailer to answer    *
  7. rem * the phone. 3rd runs in LOCAL mode.                 *
  8. rem * All three nodes access IMail for echo/netmail      *
  9. rem * tossing and scanning.                              *
  10. rem *                                                    *
  11. rem ******************************************************
  12.  
  13. rem ******************************************************
  14. rem * set port variable dependent on each node           *
  15. rem ******************************************************
  16. if %node% == N1 set port=1
  17. if %node% == N2 set port=2
  18. if %node% == N3 set port=0
  19. echo Selected Port is %port%.
  20.  
  21. rem ******************************************************
  22. rem * set up variables for each node. *NOTE* FD must     *
  23. rem * have a seperate system directory for each node.    *
  24. rem ******************************************************
  25. set fd=c:\fd\%node%
  26. set ra=c:\ra
  27. set raovr=c:\ra
  28. set imail=c:\imail
  29.  
  30. rem ******************************************************
  31. rem * load BNU for each node. once loaded, it doesn't    *
  32. rem * take any more memory to run.                       *
  33. rem ******************************************************
  34. bnu /t=2048 /f
  35.  
  36. rem ******************************************************
  37. rem * All this mess loops back to here each time.        *
  38. rem * make sure we are on the correct drive and go to    *
  39. rem * the correct directory for each node. Then run the  *
  40. rem * correct FD for each node. Each FD has a different  *
  41. rem * setup and control files!                           *
  42. rem * *NOTE* We are NOT running in Shell to Mailer mode! *
  43. rem ******************************************************
  44.  
  45. :start
  46. rem ******************************************************
  47. rem * make sure the lockout files are NOT there incase   *
  48. rem * of a system error or failure!                      *
  49. rem ******************************************************
  50. echo Removing old %node% lockout files.
  51. if exist c:\ra\%node%*.txt del c:\ra\%node%*.txt
  52.  
  53. echo The Spirit of Support -=FBBS=- Node %node% is going back online!
  54. c:
  55. cd\ra\%node%
  56.  
  57. rem ******************************************************
  58. rem * if we are node 3 goto local logon only!            *
  59. rem ******************************************************
  60. if %node% == N3 goto ralocal
  61.  
  62.  
  63. c:\fd\%node%\fd.exe
  64.  
  65. rem ******************************************************
  66. rem * check errorlevels from FD. if call is human, set   *
  67. rem * correct baud rate before loading RA.               *
  68. rem ******************************************************
  69. if errorlevel 240 set baud=2400
  70. if errorlevel 240 goto racall
  71. if errorlevel 120 set baud=1200
  72. if errorlevel 120 goto racall
  73. if errorlevel 110 set baud=300
  74. if errorlevel 110 goto racall
  75. if errorlevel 101 goto outbound
  76. if errorlevel 100 goto inbound
  77. if errorlevel 40 goto ralocal
  78. if errorlevel 34 goto roboevent
  79. if errorlevel 33 goto nightly
  80. if errorlevel 32 goto endok
  81. if errorlevel 31 goto weekly
  82. if errorlevel 10 goto endok
  83. if errorlevel 1 goto enderror
  84.  
  85. rem ******************************************************
  86. rem * check to see if the other node is tossing inbound  *
  87. rem * mail. if so let the caller know and exit. otherwise*
  88. rem * create utility lockout file for individual nodes   *
  89. rem * as they come online for a human caller and load    *
  90. rem * RA with environment variables set for each node.   *
  91. rem ******************************************************
  92. :racall
  93. cls
  94. echo We have a caller!
  95. if exist c:\ra\N?toss.txt goto fdbusy
  96. rem > c:\ra\%node%isup.txt
  97. ra -%node% -C%port% -b%baud% -e20
  98.  
  99. rem ******************************************************
  100. rem * check errorlevels after RA exit.                   *
  101. rem ******************************************************
  102. if errorlevel 20 goto update
  103. if errorlevel 5 goto outbound
  104. if errorlevel 4 goto outbound
  105. if errorlevel 3 goto outbound
  106. IF errorlevel 1 goto enderror
  107. if errorlevel 0 goto endok
  108.  
  109. rem ******************************************************
  110. rem * we have inbound mail! take node 1's phone off hook *
  111. rem * and make sure node 2 is not online before tossing. *
  112. rem * if node 2 IS online, create a mailwaiting file so  *
  113. rem * the waiting mail can be processed as soon as node  *
  114. rem * is finished. in this case, we will let node 2 run  *
  115. rem * the tosser otherwise node 1 will always toss.      *
  116. rem * this is so that node 1 can be ready to accept      *
  117. rem * human callers as soon as possible.                 *
  118. rem ******************************************************
  119.  
  120. :inbound
  121. cls
  122. echo We have inbound mail!
  123. if exist c:\ra\N?toss.txt goto innodechk
  124. if exist c:\ra\N3outchk.txt goto 3upin
  125. if exist c:\ra\N1outchk.txt goto 2upin
  126. if exist c:\ra\N2outchk.txt goto 1upin
  127. if %node% == N1 goto downthisnode
  128. if %node% == N2 goto downthisnode
  129. if %node% == N3 goto 3upin
  130.  
  131. rem ******************************************************
  132. rem * if we have just recieved a mail packet while we    *
  133. rem * are already tossing one, we will wait till next    *
  134. rem * time to toss it, so don't worry about it right now *
  135. rem ******************************************************
  136.  
  137. :innodechk
  138. if %node% == N1 goto start
  139. if %node% == N2 goto start
  140. if %node% == N3 del c:\ra\%node%*.txt
  141. If %node% == N3 goto end
  142.  
  143. rem ******************************************************
  144. rem * take node  offhook                                 *
  145. rem ******************************************************
  146.  
  147. :downthisnode
  148. dtr com%port%: on
  149. at com%port%: h1
  150. rem dtr com%port%: off
  151. if %node% == N1 goto 2upin
  152. if %node% == N2 goto 1upin
  153.  
  154. rem ******************************************************
  155. rem * check for node 1 and node 2 online                 *
  156. rem * if so, create waiting mail file.                   *
  157. rem ******************************************************
  158.  
  159. :3upin
  160. if exist c:\ra\N1isup.txt goto 3upin1
  161. if exist c:\ra\N2isup.txt goto 3upin1
  162.  
  163. rem ******************************************************
  164. rem * otherwise toss the mail!                           *
  165. rem ******************************************************
  166.  
  167. goto tossit
  168.  
  169. rem ******************************************************
  170. rem * create mail file and loop back to start            *
  171. rem ******************************************************
  172.  
  173. :3upin1
  174. rem > c:\ra\mail!.txt
  175. if exist c:\ra\%node%*.txt del c:\ra\%node%*.txt
  176. goto end
  177.  
  178. rem ******************************************************
  179. rem * check for node 2 and node 3 online                 *
  180. rem * if so, create waiting mail file.                   *
  181. rem ******************************************************
  182.  
  183. :2upin
  184. if exist c:\ra\N2isup.txt goto 2upin1
  185. if exist c:\ra\N3isup.txt goto 2upin1
  186.  
  187. rem ******************************************************
  188. rem * otherwise toss the mail!                           *
  189. rem ******************************************************
  190.  
  191. goto tossit
  192.  
  193. rem ******************************************************
  194. rem * create mail file and loop back to start            *
  195. rem ******************************************************
  196.  
  197. :2upin1
  198. rem > c:\ra\mail!.txt
  199. goto start
  200.  
  201. rem ******************************************************
  202. rem * check for node 1 and node 3 online                 *
  203. rem * if so, create waiting mail file.                   *
  204. rem ******************************************************
  205.  
  206. :1upin
  207. if exist c:\ra\N1isup.txt goto 1upin1
  208. if exist c:\ra\N3isup.txt goto 1upin1
  209.  
  210. rem ******************************************************
  211. rem * otherwise toss the mail!                           *
  212. rem ******************************************************
  213.  
  214. goto tossit
  215.  
  216. rem ******************************************************
  217. rem * create mail file and loop back to start            *
  218. rem ******************************************************
  219.  
  220. :1upin1
  221. rem > c:\ra\mail!.txt
  222. goto start
  223.  
  224. rem ******************************************************
  225. rem * do the tossing and kill the mail waiting flag file *
  226. rem * also, notify both FD nodes to rescan their message *
  227. rem * image in memory.                                   *
  228. rem ******************************************************
  229.  
  230. :tossit
  231. rem > c:\ra\%node%toss.txt
  232. echo   >> c:\fd\im.log
  233. echo Node %node% tossed this mail bundle. >> c:\fd\im.log
  234. imail toss
  235. cls
  236. imthings import
  237. rem > c:\fd\n1\fdrescan.now
  238. rem > c:\fd\n2\fdrescan.now
  239. cls
  240. ramsg -pkra
  241. if exist c:\ra\mail!.txt    del c:\ra\mail!.txt
  242. if exist c:\ra\N?toss.txt   del c:\ra\N?toss.txt
  243. if exist c:\ra\%node%outchk.txt goto backfromtoss
  244. if %node% == N3 goto N3exit
  245. goto start
  246.  
  247. rem ******************************************************
  248. rem * one of the nodes is comming online in local mode.  *
  249. rem * make the nodeisup file to let the other one know   *
  250. rem * what is going on and load RA with the node number  *
  251. rem * in local mode.                                     *
  252. rem ******************************************************
  253.  
  254. :ralocal
  255. if %node% == N1 goto tosschk1l
  256. if %node% == N2 goto tosschk2l
  257. if %node% == N3 goto tosschk3l
  258. :tosschk1l                   
  259. if exist c:\ra\N2toss.txt goto fdbusyl
  260. if exist c:\ra\N3toss.txt goto fdbusyl
  261. :tosschk2l
  262. if exist c:\ra\N1toss.txt goto fdbusyl
  263. if exist c:\ra\N3toss.txt goto fdbusyl
  264. :tosschk3l
  265. if exist c:\ra\N1toss.txt goto fdbusyl
  266. if exist c:\ra\N2toss.txt goto fdbusyl
  267. rem > c:\ra\%node%isup.txt
  268. set oldport=%port%
  269. set port=0
  270. ra -%node% -l -e20
  271. set port=%oldport%
  272.  
  273. rem ******************************************************
  274. rem * check errorlevels on local mode exit and execute.  *
  275. rem ******************************************************
  276.  
  277. if errorlevel 20 goto update
  278. if errorlevel 5 goto outbound
  279. if errorlevel 4 goto outbound
  280. if errorlevel 3 goto outbound
  281.  
  282. rem ******************************************************
  283. rem * local fdbusy display                               *
  284. rem ******************************************************
  285.  
  286. :fdbusyl
  287. type c:\ra\fdbusy.txt
  288. dvcomand wait 40
  289. goto start
  290.  
  291. rem ******************************************************
  292. rem * normal fdbusy display                              *
  293. rem ******************************************************
  294.  
  295. :fdbusy
  296. echo Notifying user of System Maintainence in progress.
  297. type c:\ra\fdbusy.txt > com%port%:
  298.  
  299. rem dtr com%port%: on
  300. rem at com%port%: h
  301. dtr com%port%: off
  302. dtr com%port%: on
  303. at com%port%: h1
  304. rem dtr com%port% off
  305. goto start
  306.  
  307. rem ******************************************************
  308. rem * ok, now we can do the outbound stuff               *
  309. rem * first check to see which node we are. then see if  *
  310. rem * we have any inbound waiting to be tossed.          *
  311. rem ******************************************************
  312.  
  313. :outbound
  314. if %node% == N1 goto downnode
  315. if %node% == N2 goto downnode
  316. if %node% == N3 goto 3upout
  317.  
  318. rem ******************************************************
  319. rem * take node  offhook                                 *
  320. rem ******************************************************
  321.  
  322. :downnode
  323. dtr com%port%: on
  324. at com%port%: h1
  325. rem dtr com%port%: off
  326. if %node% == N1 goto 2upout
  327. if %node% == N1 goto 1upout
  328.  
  329. rem ******************************************************
  330. rem * check to see if we have inbound waiting.           *
  331. rem * if so, let's try to toss it before we scan         *
  332. rem * outbound, otherwise, let's do the real thing.      *
  333. rem ******************************************************
  334.  
  335. :3upout
  336. :2upout
  337. :1upout
  338. if not exist c:\ra\mail!.txt goto jump
  339. rem > c:\ra\%node%outchk.txt
  340. goto inbound
  341. :jump
  342.  
  343. rem ******************************************************
  344. rem * we return here if we had to toss inbound before we *
  345. rem * scan for outbound.                                 *
  346. rem ******************************************************
  347.  
  348. :backfromtoss
  349. if exist c:\ra\%node%outchk.txt del c:\ra\%node%outchk.txt
  350. if %node% == N1 goto 1echoloop
  351. if %node% == N2 goto 2echoloop
  352. if %node% == N3 goto 3echoloop
  353. :1echoloop
  354. if not exist c:\ra\N2isup.txt goto chk3
  355. goto start
  356. :2echoloop
  357. if not exist c:\ra\N1isup.txt goto chk3
  358. goto start
  359. :3echoloop
  360. if not exist c:\ra\N1isup.txt goto chk2
  361. if exist c:\ra\%node%isup.txt del c:\ra\%node%isup.txt
  362. goto end
  363. :chk2
  364. if not exist c:\ra\N2isup.txt goto echook
  365. if exist c:\ra\%node%isup.txt del c:\ra\%node%isup.txt
  366. goto end
  367. :chk3
  368. if not exist c:\ra\N3isup.txt goto echook
  369. goto start
  370.  
  371. rem ******************************************************
  372. rem * ok, now we are ready to scan for outbound mail.    *
  373. rem * when done, notify both FD nodes to rescan their    *
  374. rem * message base image in memory.                      *
  375. rem ******************************************************
  376.  
  377. :echook
  378. imail scan
  379. rem > c:\fd\n1\fdrescan.now
  380. rem > c:\fd\n2\fdrescan.now
  381.  
  382. rem ******************************************************
  383. rem * ok. now we try to update the bulletins and such.   *
  384. rem * we first check to see if the other node is up. if  *
  385. rem * it is, then we let it handle everything when it    *
  386. rem * exits.                                             *
  387. rem ******************************************************
  388.  
  389. :update
  390. if exist c:\ra\mail!.txt goto inbound
  391. if exist c:\ra\msgs\echomail.bbs goto outbound
  392. if exist c:\ra\msgs\netmail.bbs goto outbound
  393. if %node% == N1 goto check1
  394. if %node% == N2 goto check2
  395. if %node% == N3 goto check3
  396. :check3
  397. if not exist c:\ra\N1isup.txt goto chck2
  398. if exist c:\ra\%node%isup.txt del c:\ra\%node%isup.txt
  399. goto end
  400. :check2
  401. if not exist c:\ra\N1isup.txt goto chck3
  402. if exist c:\ra\%node%isup.txt del c:\ra\%node%isup.txt
  403. goto start
  404. :check1
  405. if not exist c:\ra\N2isup.txt goto chck3
  406. if exist c:\ra\%node%isup.txt del c:\ra\%node%isup.txt
  407. goto start
  408. :chck2
  409. if not exist c:\ra\N2isup.txt goto doupdate
  410. if exist c:\ra\%node%isup.txt del c:\ra\%node%isup.txt
  411. goto end
  412. :chck3
  413. if not exist c:\ra\N3isup.txt goto doupdate
  414. if exist c:\ra\%node%isup.txt del c:\ra\%node%isup.txt
  415. goto start
  416. :doupdate
  417. usa
  418. :n3exit
  419. del c:\ra\%node%isup.txt
  420. if %node% == N3 goto end
  421. goto start
  422.  
  423. rem ******************************************************
  424. rem * all nightly maintenence is done by node 1.         *
  425. rem * make sure the other node is not doing anything     *
  426. rem * first. if it is, then wait a minute and try again. *
  427. rem ******************************************************
  428.  
  429. :nightly
  430. if exist c:\ra\N1*.txt del N1*.txt
  431. if exist c:\ra\N2*.txt goto wait
  432. if exist c:\ra\N3*.txt goto wait
  433. if %node% == N1 dtr com1: on
  434. if %node% == N1 at com1: h1
  435. call c:\fd\runmaint.bat
  436. goto start
  437.  
  438. rem ******************************************************
  439. rem * we come here to wait for the other node to go down *
  440. rem ******************************************************
  441.  
  442. :wait
  443. dvcomand wait 30
  444. goto nightly
  445.  
  446. rem ******************************************************
  447. rem * weekly maintenence is done by node 1.              *
  448. rem ******************************************************
  449.  
  450. :weekly
  451. if %node% == N1 dtr com1: on
  452. if %node% == N1 at com1 h1
  453. imthings stat
  454. goto start
  455.  
  456. rem ******************************************************
  457. rem * OOPS! we have some kind of error!                  *
  458. rem ******************************************************
  459.  
  460. :enderror
  461. cls
  462. echo The BBS is down with a FATAL error and the phone is off the hook!
  463. goto end
  464.  
  465. rem ******************************************************
  466. rem * normal exit from any node                          *
  467. rem ******************************************************
  468.  
  469. :endok
  470. cls
  471. dtr com%port%: on
  472. at com%port%: h1
  473. :endok2
  474. echo The BBS has been exited normally. The phone is unuseable.
  475.  
  476. rem ******************************************************
  477. rem * make sure we kill any existing lockout files       *
  478. rem * also, unload BNU from memory in this window.       *
  479. rem ******************************************************
  480. :end
  481. if exist c:\ra\%node%isup.txt del c:\ra\%node%isup.txt
  482.